package com.queclink.ycm.thread;

import com.queclink.ycm.controller.TcpController;
import com.queclink.ycm.tcp.GatewayTcpServer;
import lombok.SneakyThrows;

import java.util.HashMap;

/**
 * @author jim.li
 * @email jim.li@queclink.com
 * @date 2022-01-10 10:02:00
 */
public class TcpThread extends Thread {

    volatile boolean isStop = false; //线程退出标志


    private Integer port;

    public TcpThread(Integer port) {
        this.port = port;
    }

    public void setStop() {
        this.isStop = true;
    }

    @SneakyThrows
    @Override
    public void run() {
        super.run();
        new GatewayTcpServer().startup(port);
    }

//    @SneakyThrows
//    @Override
//    public void run() {
//        int count = 0;
//        while(!TcpController.isStopMap.get(port)){ //安全退出判断
//            System.out.println(this.getName() + ": is running .......");
//            super.run();
//            new GatewayTcpServer().startup(port);
//            Thread.sleep(10000); //设置休眠1秒
//            System.out.println(this.getName() + port + "：count = " + count++);
//        }
//        System.out.println(this.getName() + "：线程已结束！");
//    }


}
